//config的设置是全局的
layui.config({
    base: '/js/plugins/' // 自定义扩展插件所在的目录
}).extend({ //设定模块别名
    yjsloading: 'yjsloading',
});

layui.use(['form', 'yjsloading'], function () {
    var $ = layui.jquery
        , form = layui.form
        , yjsloading = layui.yjsloading;

    // 自定义表单验证规则
    form.verify({});

    // 重新获取验证码
    $('.getLVcode').click(function () {
        var url = '/vcode/path/form';
        yjsloading.loadingCaptcha(url);
    });

    // 监听部门信息表单确定按钮事件
    form.on('submit(toolbarEvent)', function (data) {
        var eventType = data.field.viewType;
        var url, msg = '';

        switch (eventType) {
            case "deleteData":
                url = '/departments/delete';
                msg = '您确定执行本次数据删除操作吗？';
                postData = data.field;
                break;
            case "deleteBatchData":
                url = '/departments/delete/batch';
                msg = '您确定执行本次数据批量删除操作吗？';
                postData = data.field;
                break;
        }
        title = '部门信息维护';

        yjsloading.ajaxConfirm(title, msg, url, postData, function (result) {
            $('#rspStatus').val(result['rspStatus']);
            $('#rspMsg').val(result['rspMsg']);
        });
    });

    // 监听个人信息表单取消按钮事件
    $('.cancelEvent').click(function () {
        var title, msg = '';
        title = '专业信息维护';
        msg = '您确定取消本次数据更新操作吗？';
        yjsloading.cancelConfirm(title, msg);
    });

});